/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
/*
 *  Copyright (c) 2019-2021  <a href="https://github.com/somowhere/albedo">Albedo</a>, somewhere (somewhere0813@gmail.com).
 *  <p>
 *  Licensed under the GNU Lesser General Public License 3.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  <p>
 * https://www.gnu.org/licenses/lgpl.html
 *  <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.albedo.java.common.security.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * RequestMethodEnum
 *
 * @author somewhere
 */
@Getter
@AllArgsConstructor
public enum RequestMethodEnum {

	/**
	 * 搜寻 @AnonymousGetMapping
	 */
	GET("GET"),

	/**
	 * 搜寻 @AnonymousPostMapping
	 */
	POST("POST"),

	/**
	 * 搜寻 @AnonymousPutMapping
	 */
	PUT("PUT"),

	/**
	 * 搜寻 @AnonymousPatchMapping
	 */
	PATCH("PATCH"),

	/**
	 * 搜寻 @AnonymousDeleteMapping
	 */
	DELETE("DELETE"),

	/**
	 * 否则就是所有 Request 接口都放行
	 */
	ALL("All");

	/**
	 * Request 类型
	 */
	private final String type;

	public static RequestMethodEnum find(String type) {
		for (RequestMethodEnum value : RequestMethodEnum.values()) {
			if (type.equals(value.getType())) {
				return value;
			}
		}
		return ALL;
	}

}
